//
//  BCOderDetailAlert.m
//  BangcaiBuy
//
//  Created by lsy on 16/7/12.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCOderDetailAlert.h"
#import "BCOderDetailAlertCell.h"
@interface BCOderDetailAlert ()<UITableViewDelegate, UITableViewDataSource>
{
    UIImageView *headBackImg;
    UIImageView *backImg;
    UILabel *headTitle;
    UIButton *okButton;
}

@property(nonatomic, strong)UITableView *table;

@end

@implementation BCOderDetailAlert
- (void)createView
{
    headBackImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg"]];
    backImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg-1"]];
    headTitle = [[UILabel alloc] init];
    headTitle.text = @"价格详情";
    headTitle.font = [UIFont systemFontOfSize:16];
    headTitle.textColor = [UIColor colorWithRed:0.173  green:0.755  blue:0.368 alpha:1];
    [headBackImg addSubview:headTitle];
    [self addSubview:backImg];
    [self addSubview:headBackImg];
    
    self.backgroundColor = [UIColor clearColor];
    okButton = [UIButton buttonWithType:UIButtonTypeSystem];
    okButton.backgroundColor = [UIColor colorWithRed:0.061  green:0.747  blue:0.338 alpha:1];
    [okButton setTitle:@"确定" forState:UIControlStateNormal];
    okButton.tintColor = [UIColor whiteColor];
    okButton.titleLabel.font = [UIFont systemFontOfSize:16];
    okButton.layer.cornerRadius = 35;
    okButton.layer.shadowColor = [UIColor darkGrayColor].CGColor;
    [okButton.layer setShadowOpacity:1.0];
    okButton.layer.shadowOffset = CGSizeMake(.7, .7);
    [okButton setClipsToBounds:NO];
    
    [okButton addTarget:self action:@selector(okBut) forControlEvents:UIControlEventTouchUpInside];
    
       
    self.table = [[UITableView alloc] init];
    self.table.delegate = self;
    self.table.dataSource = self;
    self.table.rowHeight = 28;
    
    self.table.separatorStyle = UITableViewCellSelectionStyleNone;
    [self.table registerClass:[BCOderDetailAlertCell class] forCellReuseIdentifier:@"order"];
    [self addSubview:self.table];
    
    [self addSubview:okButton];
    
    [backImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-35);
        make.left.and.right.mas_equalTo(0);
        
    }];
    
    [headBackImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(50);
        make.left.and.right.mas_equalTo(0);
        make.centerX.mas_equalTo(0);
    }];
    
    [self.table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(headBackImg.mas_bottom);
        make.width.equalTo(self);
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(-45);
        
    }];
    
    [headTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        
    }];
    
    [okButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.and.width.mas_equalTo(70);
    }];
}

- (void)okBut{
    BCAlertView *alert = (BCAlertView *)self.superview;
    [alert hide];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 8;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    BCOderDetailAlertCell *cell = [tableView dequeueReusableCellWithIdentifier:@"order"];
    cell.name = @"牛腩(高级)";
    cell.price = @"¥3.52/斤";
    cell.amount = @"x 30";
    cell.totalPrice = @"¥165.00";
    return cell;
}

@end
